#include<stdio.h>

int main()
{
	int n,a[100],i,j,k,m,t,s;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		t=0;
		scanf("%d",&m);
		while (m!=0)
		{
			a[t]=m%10;
			m=m/10;
			t++;
		}
		for (j=0;j<t;j++)
			for (k=0;k<t-1-j;k++)
				if (a[k]<a[k+1])
				{
					s=a[k];
					a[k]=a[k+1];
					a[k+1]=s;
				}
		for (j=0;j<t;j++)
			printf("%d",a[j]);
		printf("\n");
	}
} 
